package com.neothefox.romashka;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public class Layout {

	public String[][][] charmap;
	public enum TYPE {NUMERIC, MAIN, USER};
	public TYPE type;
	
	public Layout()
	{
		
	}
	
	public boolean setUser(File layout) throws IOException
	{
		BufferedReader buffer = new BufferedReader(new FileReader(layout));
		for(int i=0; i < 8; i++)
		{
			for(int j = 0; j<2; j++)
			{
				String tmp = buffer.readLine();
				for(int k = 0; k<4; k++)
				{
					charmap[i][j][k] = tmp.substring(k,k+1);
				}
			}
		}
		this.type = TYPE.USER;
		buffer.close();
		return true;
	}
	
	public void setMain()
	{
		String[][][] tmp = {
				{
					{"A","B","C","D"}, {"a","b","c","d"}
				},
				{
					{"E","F","G","H"}, {"e","f","g","h"}
				},
				{
					{"I","J","K","L"}, {"i","j","k","l"}
				},
				{
					{"M","N","O","P"}, {"m","n","o","p"}
				},
				{
					{"Q","R","S","T"}, {"q","r","s","t"}
				},
				{
					{"U","V","W","X"}, {"u","v","w","x"}
				},
				{
					{"Y","Z","?","!"}, {"y","z",",","."}
				},
				{
					{"-","_","|","\\"}, {"-","_","|","\\"}
				}
		};
		this.charmap = tmp.clone();
		this.type = Layout.TYPE.MAIN;
	}
	
	public void setNumeric()
	{
		String[][] tmp =  {
				{"1","2","3","4"},
				{"5","6","7","8"},
				{"9", "0", "+", "-"},
				{"@", "#", "$", "%"},
				{"^","&","*","(",")"},
				{"=", "<",">","|"},
				{"[","]","{","}"},
				{"~", "\"","\'","\\"}
			};
		
		for(int i = 0; i < 8; i++)
		{
			this.charmap[i][0] = tmp[i].clone();
			this.charmap[i][1] = tmp[i].clone();
		}
		this.type = Layout.TYPE.NUMERIC;
	}
}
